import { login } from '@/api/user'
import { setToken } from '@/utils/storege'
export default {
  namespaced: true,
  state: {
    token: null,
    loginName: '',
    userId: ''
  },
  mutations: {
    setToken (state, payload) {
      state.token = payload.token
      state.userId = payload.userId
      setToken(payload.token)
    }
  },
  actions: {
    async loginActions ({ commit }, payload) {
      const res = await login(payload)
      commit('setToken', res)
    }
  }
}
